package builders;

import org.joda.time.DateTime;

import books.Book;
import books.BookInfo;

/**
 */
public class BookBuilder implements IBuilderExampler<Book> {

    private BookInfo info;

    private boolean available;

    private long code;

    private DateTime registrationDate;

    public BookInfo getInfo() {
        return this.info;
    }

    public void setInfo(final BookInfo info) {
        this.info = info;
    }

    public boolean isAvailable() {
        return this.available;
    }

    public void setAvailable(final boolean available) {
        this.available = available;
    }

    public long getCode() {
        return this.code;
    }

    public void setCode(final long code) {
        this.code = code;
    }

    public DateTime getRegistrationDate() {
        return this.registrationDate;
    }

    public void setRegistrationDate(final DateTime registrationDate) {
        this.registrationDate = registrationDate;
    }

    public BookBuilder withCode(final long aCode) {
        this.code = aCode;
        return this;
    }

    public BookBuilder withAvailability(final Boolean bool) {
        this.available = bool;
        return this;
    }

    public BookBuilder withBookInfo(final BookInfo aBookInfo) {
        this.info = aBookInfo;
        return this;
    }

    public BookBuilder withDate(final DateTime aDate) {
        this.registrationDate = aDate;
        return this;
    }

    @Override
    public Book build() {
        return new Book(this);
    }

    @Override
    public Book example() {
        return new BookBuilder().withAvailability(true).withCode(Long.valueOf(123456789)).withDate(DateTime.now())
                .withBookInfo(new BookInfoBuilder().example()).build();
    }
}
